﻿using System;
using System.Windows.Forms;
using System.ComponentModel.Composition;

namespace AddinSample
{
    [InheritedExport(typeof(IContextMenuPlugin))]
    public class ContextMenuSample : IContextMenuPlugin
    {
        private SS.Ynote.Classic.Editor Edit = null;
        private ToolStripMenuItem item;
        public SS.Ynote.Classic.Editor Parent
        {
            get
            {
                return Edit;
            }
            set
            {
                Edit = value;
            }
        }

        public System.Windows.Forms.ToolStripMenuItem MainMenuItem
        {
            get { return item; }
        }

        public void Dispose()
        {
            Init();
        }
        private void Init() {
            item = new ToolStripMenuItem();
            ToolStripMenuItem item1 = new ToolStripMenuItem();
            ToolStripMenuItem item2 = new ToolStripMenuItem();
            item.Text = "Copy Advanced";
            item.DropDownItems.AddRange(new ToolStripItem[] { item1, item2, });
            item1.Text = "As HTML";
            item1.Click += new EventHandler(item1_Click);
            item2.Text = "As RTF";
            item2.Click += new EventHandler(item2_Click);
        }
        private void item1_Click(object sender, EventArgs e)
        {
            Clipboard.SetText(Parent.codebox.Html);
        }
        private void item2_Click(object sender, EventArgs e)
        {
            Clipboard.SetText(Parent.codebox.Rtf);
        }
        public string Name
        {
            get { return "Sample Context Menu"; }
        }

        public string Version
        {
            get { return "1.0"; }
        }

        public string Author
        {
            get { return "Ynote Classic"; }
        }

        public string Description
        {
            get { return "Simple Plugin"; }
        }
    }
}
